package com.gitee.wsl.ext.number

/**
 * Checks if a Long number is a palindrome.
 * A palindrome is a number that reads the same forward and backward.
 *
 * @return `true` if the number is a palindrome, `false` otherwise.
 */
fun Long.isPalindrome(): Boolean = this == this.reverse()

/**
 * Checks if a Long number is a super palindrome.
 * A super palindrome is defined as a number that remains a palindrome
 * after dividing it by 2 twice.
 *
 * @return `true` if the number is a super palindrome, `false` otherwise.
 */
fun Long.isSuperPalindrome(): Boolean {
    var currentNumber = this
    var isSuperPalindrome = false
    repeat(2) {
        isSuperPalindrome = currentNumber.isPalindrome()
        currentNumber /= 2
        if (!isSuperPalindrome) {
            return false
        }
    }
    return isSuperPalindrome
}